package com.deviche.taobao;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;


import com.alibaba.android.arouter.launcher.ARouter;
import com.deviche.library.net.NetHelper;

import java.util.ArrayList;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;


public class MainActivity extends AppCompatActivity {


    public static final String TAG = MainActivity.class.getSimpleName();

    ViewPager mViewPager;

    TabLayout mTabLayout;

    ArrayList<String> mTitleDataList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTitleDataList = new ArrayList<>();
        mTitleDataList.add(getString(R.string.JHS));
        mTitleDataList.add(getString(R.string.JHS));
        mTitleDataList.add(getString(R.string.JHS));
        mTitleDataList.add(getString(R.string.JHS));
        mTitleDataList.add(getString(R.string.JHS));

        initIndicator();
    }

    private void initIndicator() {
        mViewPager = findViewById(R.id.view_pager);

        mTabLayout = findViewById(R.id.tabLayout);

        findViewById(R.id.bt_jump).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ARouter.getInstance()
                        .build("/view/activity1")
                        .navigation();
            }
        });


//        mTabLayout.addTab(new TabLayout.Tab());
//        mTabLayout.addTab(new TabLayout.Tab());
//        mTabLayout.addTab(new TabLayout.Tab());

//        getData();

    }

    private void getData() {

//        Log.e(TAG, "getData: 8888888888888888888");
        CallService callService = NetHelper.getRetrofit().create(CallService.class);

        Observable<DataBean> data = callService.getData();

        data.observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new Observer<DataBean>() {

            @Override
            public void onError(Throwable e) {
                Log.e(TAG, "onError: +777777777777"+e.getMessage());
            }

            @Override
            public void onComplete() {
                Log.e(TAG, "onComplete: +999999999999999999");
            }

            @Override
            public void onSubscribe(Disposable d) {
                Log.e(TAG, "onSubscribe: +444444444444");
            }

            @Override
            public void onNext(DataBean value) {
                Log.e(TAG, "onNext: ---------" +value.getResults().getApp().size());
            }

        });

    }

}
